/* Copyright (C) 2010 Albert Faber

GCC is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free
Software Foundation; either version 3, or (at your option) any later
version.

GCC is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
for more details.

You should have received a copy of the GNU General Public License
along with GCC; see the file COPYING3.  If not see
<http://www.gnu.org/licenses/>.  */

#ifndef JAL_CPP_H
#define JAL_CPP_H

#include "cpplib.h"
#include "line-map.h"


enum spell_type
{
  SPELL_OPERATOR = 0,
  SPELL_IDENT,
  SPELL_LITERAL,
  SPELL_NONE
};

struct token_spelling
{
  enum spell_type category;
  const unsigned char *name;
};


#ifndef UC
	#define UC (const unsigned char *)  /* Intended use: UC"string" */
#endif


#define OP(e, s) { SPELL_OPERATOR, UC s  },
#define TK(e, s) { SPELL_ ## s,    UC #e },
static const struct token_spelling token_spellings[N_TTYPES] = { TTYPE_TABLE };
#undef OP
#undef TK

#define TOKEN_SPELL(token) (token_spellings[(token).type].category)
#define TOKEN_NAME(token) (token_spellings[(token).type].name)



typedef struct JAL_CPP_TOKEN_TYPE
{
	enum cpp_ttype id;
	char* fileName;
	int currentLine;
	int currentCol;
	char* token_string;
	size_t token_size;
	location_t location;
} JAL_CPP_TOKEN;


/* FUNCTIONs */
JAL_CPP_TOKEN jal_pp_next_token(bool expect_include_filename);
bool jal_pp_set_filename(const char* fileName);
void *jal_alloc (size_t size);
void print_jal_token(JAL_CPP_TOKEN* token_ptr);


#endif /* JAL_CPP_H */
